package session09;

import session09.compent.ATMBackPanel;
import session09.compent.JButtonPanel;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class IndexPanel extends ATMBackPanel {
    private JButtonPanel loginBtn;
    private JButtonPanel exitBtn;
    private JButtonPanel registerBtn;

    public IndexPanel(ATMFrame frame) {
        this.loginBtn = new JButtonPanel("image/buttonLogin.jpg", 50, 650);
        this.loginBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Container atm = frame.getContentP();
                CardLayout cardLayout = (CardLayout) atm.getLayout();
                cardLayout.show(atm, "login");
            }
        });

        this.exitBtn = new JButtonPanel("image/buttonOff.jpg", 442, 650);
        this.exitBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.exit(0);
            }
        });
        this.registerBtn = new JButtonPanel("image/buttonRegister.jpg", 832, 650);
        this.registerBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Container atm = frame.getContentP();
                CardLayout cardLayout = (CardLayout) atm.getLayout();
                cardLayout.show(atm, "register");
            }
        });

        this.getBackLab().add(this.loginBtn);
        this.getBackLab().add(this.exitBtn);
        this.getBackLab().add(this.registerBtn);
    }
}
